<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>
	<link rel="stylesheet" href="__STATIC__/Bootstrap/Css/bootstrap.min.css" />
	<link rel="stylesheet" href="__STATIC__/Admin/Css/common.css" />
	<script type="text/javascript" src='__STATIC__/Admin/Js/jquery-1.7.2.min.js'></script>
	<style type="text/css">
		#pic{display: none;}
	    .pic{
	    	width: 120px;height: 30px;
	    	background: url(__STATIC__/Admin/Images/upBtn.png) no-repeat;
	    	float: left;
	    }
	    .picImg{float: left;line-height: 29px;margin-left: 20px;}
	    .pic:hover{background: url(__STATIC__/Admin/Images/upBtn.png) no-repeat 0 -30px;}

	</style>
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">

	<form action="" method='post' enctype="multipart/form-data">
		
		<legend>添加商品品牌</legend>
		<table class="table table-bordered table-hover">
			<tr class="info">
				<td>品牌名称</td>
				<td colspan="2">
					<input type="text" name="bname" id="bname" value="" />
				</td>
			</tr>
			<tr class="info">
				<td>品牌LOGO</td>
				<td>
					
		           	<label for="pic" class="pic"></label>
					<input type="file" name='pic' id='pic'/>
					<span class="picImg"></span>
					<br><img src="" style="display:none" width="120">
				</td>
				<td>
					<!--<div id='logo-wrap' ></div>-->
				</td>
			</tr>
			<tr class="info">
				<td>是否热门</td>
				<td colspan="2">
					<input type="checkbox" name='is_hot' value="1"/>
				</td>
			</tr>
			<tr>
				<td colspan='3' align='center'>
					<input type="submit" class="btn btn-primary" value="添加品牌" />
				</td>
			</tr>
		</table>
		
	</form>

	</div>
	</div>
	</div>
<script type="text/javascript">
$(function(){
//	给两个上传按钮绑定onchange事件
	$("#pic").change(function(){
		var objUrl = getObjectURL(this.files[0]) ;
		var value=$(this).val();
//		给span标签添加商品图片的名字
		$(this).siblings('span').html(value);
		console.log("objUrl = "+objUrl) ;
		if (objUrl) {
//			给图片添加src并显示
			$(this).siblings('img').hide().attr("src", objUrl).fadeIn(300) ;
		}
	}) ;
	//建立一個可存取到該file的url
	function getObjectURL(file) {
		var url = null ; 
		if (window.createObjectURL!=undefined) { // basic
			url = window.createObjectURL(file) ;
		} else if (window.URL!=undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file) ;
		} else if (window.webkitURL!=undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file) ;
		}
		return url ;
	}
	
})
</script>

</body>
</html>